package com.softeem.music_server.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * API接口
 */
@RestController
public class UserController {

    @GetMapping("/user/info")
    public Map<String,Object> getUser(){
        Map<String,Object> user = new HashMap<>();
        user.put("id",1001);
        user.put("username","softeem");
        user.put("age",18);
        user.put("sex","男");
        user.put("phone","1888888888");
        user.put("bak","软帝集团");
        return user;
    }

    @GetMapping("/user/list")
    public List<Map<String,Object>> list(){
        List<Map<String,Object>> users = new ArrayList<>();
        for (int i = 0; i < 20; i++) {
            Map<String,Object> user = new HashMap<>();
            user.put("id",1001 + i);
            user.put("username","softeem" + i);
            user.put("age",(int)(Math.random()* 30));
            user.put("sex","男");
            user.put("phone","1888888888");
            user.put("bak","软帝集团");
            users.add(user);
        }
        return users;
    }

}
